package servlets;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import business.LaCorunaDelegator;
import dto.ArticuloDTO;

/**
 * Servlet implementation class for Servlet: OFADIndex
 *
 */
 public class OFADIndex extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
   private static final String LISTADO_TENTATIVO = "/WEB-INF/jsp/listado_tentativo.jsp";
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public OFADIndex() {
		super();
	}	
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		try {
		LaCorunaDelegator delegator = LaCorunaDelegator.getInstance();
		
		List <ArticuloDTO> listado_tentativo = delegator.getListadoTentativo();
		request.setAttribute("listado_tentativo", listado_tentativo);
		getServletContext().getRequestDispatcher(LISTADO_TENTATIVO).forward(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	/* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}   	  	    
}